<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/1/5
  Time: 10:39
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>文件树</title>
</head>
<body>
    <script>
        $(function () {
            $('#fileTree').tree({
                url:'${ctx}/fc/find',
                checkbox:true,
                line:true,
                cascadeCheck:false,
                queryParams:{
                    fileType:'dir',
                    fileSize:$('#mid').val()  //表示排除的id,暂时fileSize接收
                },
                loadFilter:function (data) {
                    //添加一个顶层根目录
                    var root = {"id":0,"name":"根路径","parentId":-1};
                    data.push(root);
                    return convert(data);
                },onSelect:function (node) {
                    singleChecked(node,'');
                }
                ,onBeforeCheck:function(node,checked){
                    singleChecked(node,checked);
                },onLoadSuccess:function () {
                    $('#fileTree .tree-icon')
                        .css("background","url(../../img/icons/v1.ico) no-repeat center center")
                        .css("width","16px").css("height","16px");
                    $(this).find('span.tree-checkbox').unbind().click(function(){
                        $('#fileTree').tree('select',$(this).parent());
                        return false;
                    });
                }
            });
        });
        function singleChecked(node,checked){
            //获取所有节点
            var cs = $('#fileTree').tree('getChecked');
            //去掉选中的节点
            for(var i=0;i<cs.length;i++){
                var id = cs[i].id;
                if(id!=node.id){
                    $('#fileTree').tree('uncheck',cs[i].target);//取消选中
                }
            }
            if(checked=='') {
                $('#fileTree').tree('check', node.target);
            }


        }


    </script>
    <div>
        <input type="hidden" id="mid" value="${mid}">
        <ul id="fileTree"></ul>
    </div>
</body>
</html>
